package cn.hackcloud.designpattern.simplefactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class OrderPizza {
	private Pizza pizza;

	public OrderPizza() {
		String orderType = "";
		do {
			orderType = getType();
			pizza = SimpleFactory.createPizza(orderType);
			if (pizza != null) {
				pizza.bake();
				pizza.cut();
				pizza.box();
			} else {
				System.err.println("无此类型披萨！");
				break;
			}
		} while (true);
	}

	public String getType() {
		InputStream in = System.in;
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
		try {
			return bufferedReader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}

	}

}
